package com.yzp.config;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;

/**
 * @title: DocumentationConfig
 * @Author: yzp
 * @Date: 2019/10/6 22:57
 * @Version 1.0
 */
@Primary
@Component
public class DocumentationConfig  implements SwaggerResourcesProvider {
    @Override
    public List<SwaggerResource> get() {
        List resources = new ArrayList<>();
        // app-itmayiedu-order
        resources.add(swaggerResource("micro-user", "/micro-user/v2/api-docs", "2.0"));
        resources.add(swaggerResource("micro-order", "/micro-order/v2/api-docs", "2.0"));
        return resources;
    }

    private SwaggerResource swaggerResource(String name, String location, String version) {
        SwaggerResource swaggerResource = new SwaggerResource();
        swaggerResource.setName(name);
        swaggerResource.setLocation(location);
        swaggerResource.setSwaggerVersion(version);
        return swaggerResource;
    }
}
